import java.util.Scanner;
import java.util.Stack;

/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-11-26
 * Time: 15:41
 */
public class demo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n= scanner.nextInt();
        Stack<Integer> num1=new Stack<>();
        Stack<Integer> num2=new Stack<>();
        Stack<Integer> ans=new Stack<>();
        for(int i=0;i<m;i++) {
            num1.add(scanner.nextInt());
        }
        for(int i=0;i<n;i++) {
            num2.add(scanner.nextInt());
        }
        int tar=2;
        int event=0;
        while(!num1.isEmpty() && !num2.isEmpty()) {
            int up=num1.pop();
            int down=num2.pop();
            int temp=(up+down+event)%tar;
            event=(up+down+event)/tar;
            ans.add(temp);
            tar++;
        }
        while(!num1.isEmpty()) {
            int f=num1.pop();
            int temp=(f+event)%tar;
            event=(f+event)/tar;
            ans.add(temp);
            tar++;
        }
        while(!num2.isEmpty()) {
            int f=num2.pop();
            System.out.println(f+event);
            int temp=(f+event)%tar;
            event=(f+event)/tar;
            ans.add(temp);
            tar++;
        }
        while(!ans.isEmpty()) {
            System.out.print(ans.pop());
            if(!ans.isEmpty()) {
                System.out.print(" ");
            }
        }
    }
}
